import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/services.dart';

class LoginAPI {
  static String loginPath;
  static String registerPath;
  Future<void> login(String user,String password)async{
    Dio dio=new Dio();
    FormData formData=new FormData.fromMap({
      "user":user,
      "password":password
    });
    Response response=await dio.post(loginPath,data:formData,);
    var data=JsonDecoder().convert(response.toString());
    if(data["code"]==0){
      //登录成功
    }
  }
  Future <void> register(String user,String password)async{
    Dio dio=new Dio();
    FormData formData=new FormData.fromMap({
      "user":user,
      "password":password
    });
    Response response=await dio.post(registerPath,data: FormData);
    var data=JsonDecoder().convert(response.toString());
    if(data["code"]==0){
      //注册成功
    }
  }
}

class Clip{
 static Future<bool> isEuropeUser() async {
    // Native channel
    const platform = const MethodChannel("com.test/name"); //分析1
    bool result = false;
    try {
      result = await platform.invokeMethod("isChinese"); //分析2
      print(result);
    } on PlatformException catch (e) {
      print(e.toString());
    }
    return result;
  }
}


